package com.ganlinux.pangoo.controller.restful.footmark;

import com.alibaba.fastjson.JSON;
import com.ganlinux.pangoo.controller.restful.base.BaseController;
import com.ganlinux.pangoo.dao.model.User;
import com.ganlinux.pangoo.dao.model.UserFootmarkList;
import com.ganlinux.pangoo.entity.request.ReqFootPrintInfo;
import com.ganlinux.pangoo.entity.request.ReqLogin;
import com.ganlinux.pangoo.entity.response.RspFootPrintInfoData;
import com.ganlinux.pangoo.entity.response.base.RspBase;
import com.jfinal.aop.Before;
import com.jfinal.kit.HttpKit;

/**
 * BlogController
 * 所有 sql 与业务逻辑写在 Model 或 Service 中，不要写在 Controller 中，养成好习惯，有利于大型项目的开发与维护
 */
@Before(FootMarkInfoInterceptor.class)
public class FootMarkInfoController extends BaseController {
	public void index() {
		super.index();
	}

	public void add() {
		super.add();
	}

	public void save() {
		if(isCheckAccess()) {
			RspBase rspLogin = new RspBase();
			String jsonString= HttpKit.readData(getRequest());
			ReqFootPrintInfo reqLogin = JSON.parseObject(jsonString, ReqFootPrintInfo.class);
			reqLogin.setReqHeader(getHeaderFromRequest(getRequest()));

			RspFootPrintInfoData rspFootPrintInfoData = UserFootmarkList.dao.getFootPrintInfo(reqLogin.getReqHeader().getPin(),reqLogin.getFootPrintId());
			if (rspFootPrintInfoData == null) {
				rspLogin.setStatus(1);
				rspLogin.setMessage("失败");
			}else{
				rspLogin.setStatus(0);
				rspLogin.setData(rspFootPrintInfoData);
				rspLogin.setMessage("成功");
			}
			renderText(JSON.toJSONString(rspLogin));
		}else {
			RspBase rspBase = new RspBase();
			rspBase.setStatus(1);
			rspBase.setMessage("身份验证失败");
			renderText(JSON.toJSONString(rspBase));
		}

	}

	public void edit() {
		super.edit();
	}

	public void update() {
		super.update();
	}

	public void delete() {
		super.delete();
	}
}


